import { Component } from 'react';
import { RichText, View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { PRIVACY_AGREEMENT, REGISTER_AGREEMENT } from './agreement';
import './index.scss';

export default class WebViewPage extends Component {
  state = {
    agreement: '',
  };
  componentDidMount() {
    const query = Taro.getCurrentInstance()?.router?.params;
    if (query?.type === 'register') {
      this.setState({
        agreement: REGISTER_AGREEMENT,
      });
    } else {
      this.setState({
        agreement: PRIVACY_AGREEMENT,
      });
    }
  }
  render() {
    return (
      <View className="agreement-content">
        <RichText nodes={this.state.agreement} />
      </View>
    );
  }
}
